
#include<stdio.h>
#include<string.h>
#include<errno.h>
#include<stdlib.h>

#define BUFSIZE 1024
 
int main(int argc, char** argv)
{
    FILE* fpr,*fpw;
    char buf[BUFSIZE];    
    int rlen,wlen;
    if(argc< 3)
    {
    	fprintf(stderr, "Usage....\n");
    	exit(1);
    }   

    fpr= fopen(argv[1], "r");
    if(fpr == NULL) 
    {
      	perror("fopen");
	      exit(1);   
    }

    fpw = fopen(argv[2],"w");
    if(fpw==NULL)
    { 
      fclose(fpr);
      perror("fopen()");
      exit(1);
    }
    
    wlen= 0;
    while((rlen = fread(buf,1,BUFSIZE, fpr))> 0)
    {
      while(rlen= rlen- wlen)
         {
           wlen= fwrite(buf,1,rlen, fpw);
         }
    }

    fclose(fpr);
    fclose(fpw);

    exit(0);
}





